package aqr;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Armstrong {

	public static void main(String[] args) {
		int number = 0;
		System.out.print("Enter the number: ");
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			number = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			System.out.println("Invalid Entry");
		}
		
		System.out.println("The answer to is the number "+number+" an Armstrong number is: "+isArmstrong(number));
		
	}
	
	public static String isArmstrong(int num) {
		if (num == 0) {
			return "TRUE";
		}
		
		int number = num;
		int result = 0;
		while(number != 0) {
			result += Math.pow(number%10, 3);
			number /= 10;
		}
		
		System.out.println("Result: "+result);
		if (result == num)
			return "YES";
		
		return "NO";
	}
	
}
